import MinPriorityQueue from '../../helper/MinPriorityQueue'

/**
 * 最小优先队列，MinPriorityQueue方法官方已提供
 * @param {number} n
 */
export var SeatManager = function (n) {
  this.seats = new MinPriorityQueue()
  for (let i = 0; i < n; i++) {
    this.seats.enqueue(i + 1, i + 1)
  }
}

/**
 * @return {number}
 */
SeatManager.prototype.reserve = function () {
  return this.seats.dequeue().element
}

/**
 * @param {number} seatNumber
 * @return {void}
 */
SeatManager.prototype.unreserve = function (seatNumber) {
  this.seats.enqueue(seatNumber, seatNumber)
}

/**
 * Your SeatManager object will be instantiated and called as such:
 * var obj = new SeatManager(n)
 * var param_1 = obj.reserve()
 * obj.unreserve(seatNumber)
 */
